package org.xq.softcup.mq.remoting.invoker.router.impl;

import org.xq.softcup.mq.remoting.invoker.router.XQRpcLoadBalance;

import java.util.Random;
import java.util.TreeSet;

public class XQRpcLoadBalanceRandomStrategy extends XQRpcLoadBalance
{
    private Random random = new Random();

    public String route(String serviceKey, TreeSet<String> addressSet)
    {
        String[] addressArr = (String[])addressSet.toArray(new String[addressSet.size()]);

        String finalAddress = addressArr[this.random.nextInt(addressSet.size())];
        return finalAddress;
    }
}
